"""
@Time ： 2022/12/9 11:11
@Auth ： 陈杰 200320501042
@E-mail : 1612845322@qq.com
"""
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session


def connect():
    conn = create_engine(
        "mysql+pymysql://root:cj2001..@localhost:3306/"
        "student?charset=utf8mb4",
        max_overflow=0,
        pool_size=5,
    )
    print("数据库连接成功！")
    return conn


def getsession():
    conn = connect()
    Session = sessionmaker(bind=conn)
    session = scoped_session(Session)
    return session


